package com.xz.primerdemo;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * @author zhangh     
 * @version V1.0.0
 * @projectName selfstudy-crawler
 * @title     JobProcessor   
 * @package    com.xz.primerdemo  
 * @date   2019/10/11 9:55  
 * @explain  WebMagic入门小案例
 */
public class JobProcessor implements PageProcessor {

    public void process(Page page) {
        page.putField("author", page.getHtml().css("div.logo>h2").all());
    }

    private Site site = Site.me();
    public Site getSite() {
        return site;
    }


    public static void main(String[] args) {
        Spider.create(new JobProcessor())
                //初始访问url地址
                .addUrl("https://www.jd.com/moreSubject.aspx")
                .run();
    }
}
